import { Column, Entity, Index } from 'typeorm';
import { CommonEntity } from '~/common/entity/common.entity';
import { ArticleContentType } from '../article/article-content/article-content.entity';

@Entity('ah_log_article')
@Index(['id'])
export class LogArticleEntity extends CommonEntity {
  @Column({ type: 'int', name: 'article_id', comment: '文章ID' })
  articleId: number;

  @Column({ type: 'int', name: 'user_id', comment: '用户ID' })
  userId: number;

  @Column({
    type: 'enum',
    enum: ArticleContentType,
    comment: '文章类型',
    default: ArticleContentType.MEDICAL_KNOWLEDGE,
    name: 'article_type',
  })
  articleType: ArticleContentType;

  @Column({ type: 'int', name: 'read_duration', comment: '阅读时长(秒)', default: 0 })
  readDuration: number;

  @Column({ type: 'int', name: 'category_id', comment: '分类ID', nullable: true })
  categoryId: number;
}
